load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "clusterversion",
    srcs = [
        "clusterversion.go",
        "cockroach_versions.go",
        "dev_offset.go",
        "setting.go",
        "testutils.go",
        "utilversions.go",
    ],
    embed = [":clusterversion_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/clusterversion",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/roachpb",
        "//pkg/settings",
        "//pkg/testutils/skip",
        "//pkg/util/envutil",
        "//pkg/util/log",
        "//pkg/util/metric",
        "//pkg/util/protoutil",
        "//pkg/util/timeutil",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_redact//:redact",
    ],
)

go_test(
    name = "clusterversion_test",
    size = "small",
    srcs = [
        "clusterversion_test.go",
        "cockroach_versions_test.go",
        "setting_test.go",
    ],
    embed = [":clusterversion"],
    deps = [
        "//pkg/build",
        "//pkg/roachpb",
        "//pkg/settings",
        "//pkg/settings/cluster",
        "//pkg/testutils",
        "//pkg/util/leaktest",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_stretchr_testify//require",
    ],
)

proto_library(
    name = "clusterversion_proto",
    srcs = ["cluster_version.proto"],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/roachpb:roachpb_proto",
        "@com_github_gogo_protobuf//gogoproto:gogo_proto",
    ],
)

go_proto_library(
    name = "clusterversion_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/clusterversion",
    proto = ":clusterversion_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/roachpb",
        "@com_github_gogo_protobuf//gogoproto",
    ],
)
